package view.option;

import datacontainer.ImmuTable;
import model.DataManager;
import view.DataVisualizer;


/**
 * This is the abstract class for creating new graphs. These
 * classes will contain the specific instructions (algorithm) to allow
 * the controller to create specific graphs.
 * 
 * @author Michael Deng modified: Jei Min Yoo
 * 
 */
public abstract class AbstractOption {

    private String mySchool;
    private DataManager myModel;
    private DataVisualizer myView;

    /**
     * returns myModel for subclasses to use.
     */
    protected DataManager getModel () {
        return myModel;
    }

    /**
     * returns myView for subclasses to use.
     */
    protected DataVisualizer getView () {
        return myView;
    }

    /**
     * returns mySchool for subclasses to use.
     */
    protected String getSchool () {
        return mySchool;
    }

    /**
     * manipulate data according to specific instructions.
     * AbstractOption only creates workspace
     * Concrete subclasses contains specific instructions
     */
    public void execute () {
        myModel.createWorkspace();
    }

    /**
     * allows the Option classes to use instances of DataManager and
     * DisplayManager
     * also gives the name of school whose data needs to be displayed
     * 
     * @param m reference to model
     * @param v reference to view
     * @param school school of interest
     */
    public void setReferences (DataManager m, DataVisualizer v, String school) {
        myModel = m;
        myView = v;
        mySchool = school;
    }

    /**
     * allows Option class to visualize data by calling view and passing data
     * 
     * @param g
     */
    protected void visualize (String g) {
        ImmuTable table = myModel.returnResult();
        myModel.resetWorkspace();
        myView.createGraph(g);
        myView.inputData(table);
    }
}
